﻿using Optum.SN.Infra.Core.Model.Repository;
using Optum.SN.Infra.Core.Dependency.Service;

namespace Optum.SN.Infra.Core.TestBase
{
    /// <summary>
    /// Common API for database unit tests.
    /// </summary>
    public abstract class DbUnitTestBase : DbTestBase
    {
        /// <summary>
        /// Creates concrete repository and sets database context.
        /// </summary>
        /// <typeparam name="T">Repository record type.</typeparam>
        /// <param name="dbContext">Database context for the repository.</param>
        /// <returns>Typed repository.</returns>
        /// <remarks>Note that since this class is meant for unit testing, logging delegate is not set here.</remarks>
        protected override IRepository<T> GetRepository<T>(IDbContext dbContext)
        {
            return new Repository<T> { DbContext = dbContext };
        }
        /// <summary>
        /// Creates concrete repository for asynchronous data access and sets database context.
        /// </summary>
        /// <typeparam name="T">Repository record type.</typeparam>
        /// <param name="dbContext">Database context for the repository.</param>
        /// <returns>Typed repository.</returns>
        /// <remarks>Note that since this class is meant for unit testing, logging delegate is not set here.</remarks>
        protected override IRepositoryAsync<T> GetRepositoryAsync<T>(IDbContext dbContext)
        {
            return new RepositoryAsync<T> { DbContext = dbContext };
        }
    }
}